#include "daysform.h"
#include "gudaywellwidget.h"
//
DaysForm::DaysForm( QWidget * parent, Qt::WFlags f) : QWidget(parent, f)
{
	setupUi(this);
	
	saturdayWidget	= new GudaywellWidget;
	sundayWidget 	= new GudaywellWidget;
	mondayWidget 	= new GudaywellWidget;
	tuesdayWidget 	= new GudaywellWidget;
	wednesdayWidget = new GudaywellWidget;
	thursdayWidget 	= new GudaywellWidget;
	
	daysTBox->addItem(saturdayWidget,"Saturday");
	daysTBox->addItem(sundayWidget,"Sunday");
	daysTBox->addItem(mondayWidget,"Monday");
	daysTBox->addItem(tuesdayWidget,"Tuesday");
	daysTBox->addItem(wednesdayWidget,"Wednesday");
	daysTBox->addItem(thursdayWidget,"Thursday");
	
	currentWidget = saturdayWidget;
	
	connect(refreshButton,SIGNAL(clicked()),this,SLOT(refresh()));
}
//
void DaysForm::on_daysTBox_currentChanged(int index)
{
	switch(index){
		case 0: currentWidget = saturdayWidget;
				break;
		case 1: currentWidget = sundayWidget;
				break;
		case 2: currentWidget = mondayWidget;
				break;
		case 3: currentWidget = tuesdayWidget;
				break;
		case 4: currentWidget = wednesdayWidget;
				break;
		case 5: currentWidget = thursdayWidget;
				break;
	}
}
//
void DaysForm::on_addButton_clicked()
{
	currentWidget->addRow();
}
//
void DaysForm::on_removeButton_clicked()
{
	currentWidget->delRow();
}

void DaysForm::refresh()
{
	saturdayWidget->model->select();
	sundayWidget->model->select();
	mondayWidget->model->select();
	tuesdayWidget->model->select();
	wednesdayWidget->model->select();
	thursdayWidget->model->select();
}
